package io;

import java.io.*;
import java.util.Scanner;

public class Txet3 {
    public static void main(String[] args) throws FileNotFoundException {
       /* PW:负责按行写出字符串
        BW:块写文本数据加速(内部有一个默认8192长度的字符数组)
        OSW:将写出的字符转字节
        FOS:将字节写入到文件中*/
        //在FileOutputStream 括号内加true开启文件追加模式
        FileOutputStream fos =new FileOutputStream("pw.txt",true);
        OutputStreamWriter osw =new OutputStreamWriter(fos);
        BufferedWriter bw =new BufferedWriter(osw);
        //再printWriter中的括号加true会自动调用flush方法 自动行刷新
        PrintWriter pw =new PrintWriter(bw,true);
        Scanner sc =new Scanner(System.in);
        System.out.println("开始输入:");
        System.out.println("输入exit退出");
        while (true){
            String next = sc.next();
            if ("exit".equalsIgnoreCase(next)){
                break;
            }
            pw.println(next);
        }
        pw.close();
    }
}
